<?php
/**
 * Created by JetBrains PhpStorm.
 * User: onwer
 * Date: 11-10-22
 * Time: 下午5:02
 * To change this template use File | Settings | File Templates.
 */
class Curl{
     protected static $cookie;
     public function __construct(){
         $this->cookie = dirname(__FILE__).'/cookie.txt';
     }
     static function getSend($url){
        $curl = curl_init($url);
            curl_setopt($curl, CURLOPT_HEADER, 0);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($curl, CURLOPT_COOKIEFILE, self::$cookie);    // 注意这里！
            $result = curl_exec($curl);
            curl_close($curl);
        return $result;
     }
     static function postSend($url,$post){

        $curl = curl_init($url);
            curl_setopt($curl, CURLOPT_HEADER, 0);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($curl, CURLOPT_COOKIEJAR, self::$cookie);
            curl_setopt($curl, CURLOPT_COOKIEFILE,self::$cookie);    // 注意这里！
            curl_setopt($curl, CURLOPT_POST, 1);
            curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));
            $result = curl_exec($curl);
            curl_close($curl);
        return $result;
    }
}